package com.aspect.aspect.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @Author: admin
 * @Description:
 * @Date: 2018/10/25 17:50
 */

@Aspect
@Component
public class SecondAspect  implements Ordered {
    @Pointcut("@annotation(com.aspect.aspect.annotation.MyAnnotation)")
    public void point(){}
    @Around("point()")
    public Object invoke(ProceedingJoinPoint proceedingJoinPoint){
        System.out.println("SecondAspect-------start");
        Object res=null;
        try {
            res= proceedingJoinPoint.proceed();
        } catch (Throwable throwable) {
            Object o= proceedingJoinPoint.getTarget();
            Class c= o.getClass();
            try {
                Method m=c.getMethod("",proceedingJoinPoint.getArgs().getClass());
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
            throwable.printStackTrace();
        }
        System.out.println("SecondAspect-------end");
        return res;
    }

    @Override
    public int getOrder() {
        return 2;
    }
}
